home *** CD-ROM | disk | FTP | other *** search
- /*
- * MultiBinder.m
- * A Binder for fetching multiple results sets from a stored procedure.
- * You may freely copy, distribute, and reuse the code in this example.
- * NeXT disclaims any warranty of any kind, expressed or implied, as to its
- * fitness for any particular use.
- * Written by Jack Greenfield
- */
-
- #import "MultiBinder.h"
-
- @implementation MultiBinder
-
- - initFromPropertyLists:(List *)propLists
- {
- if ((self = [super init]) != nil)
- {
- currentResultSet = 0;
- if (propLists) propListList = [propLists copyFromZone:[self zone]];
- }
-
- return self;
- }
-
- - (List *)getCurrentProperties:(List *)aList
- {
- return [super getProperties:aList];
- }
-
- - (unsigned int)currentResultSet
- {
- return currentResultSet ? currentResultSet - 1 : [propListList count];
- }
-
- - (List *)getProperties:(List *)aList
- {
- if (currentResultSet)
- if ([delegate respondsTo:@selector(binderWillChangeResultSet:)])
- [delegate binderWillChangeResultSet:self];
-
- [aList empty];
- [aList appendList:[propListList objectAt:currentResultSet]];
- [self setProperties:aList];
- currentResultSet++;
- if ([propListList count] && currentResultSet > [propListList count])
- currentResultSet = [propListList count];
- else
- if ([delegate respondsTo:@selector(binderDidChangeResultSet:)])
- [delegate binderDidChangeResultSet:self];
-
- return aList;
- }
-
- - free
- {
- [[propListList freeObjects] free];
- return [super free];
- }
-
- @end
-
- @implementation DBBinder (MultiBinderMethods)
-
- - (List *)getCurrentProperties:(List *)aList
- {
- return([self getProperties:aList]);
- }
-
- @end
-
-